<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - gcov.info - curves/ParametersKey.cpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">curves</a> - ParametersKey.cpp<span style="font-size: 80%;"> (source / <a href="ParametersKey.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">gcov.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">51</td>
            <td class="headerCovTableEntry">70</td>
            <td class="headerCovTableEntryLo">72.9 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2014-06-30 01:17:31</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">18</td>
            <td class="headerCovTableEntry">21</td>
            <td class="headerCovTableEntryMed">85.7 %</td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : /* </a>
<span class="lineNum">       2 </span>            :  * File:   ParametersKey.cpp
<span class="lineNum">       3 </span>            :  * Author: nichole
<span class="lineNum">       4 </span>            :  * 
<span class="lineNum">       5 </span>            :  * Created on April 26, 2014
<span class="lineNum">       6 </span>            :  */
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #include &quot;ParametersKey.h&quot;
<span class="lineNum">       9 </span>            : 
<a name="10"><span class="lineNum">      10 </span>            : namespace gev {</a>
<span class="lineNum">      11 </span>            :         
<span class="lineNum">      12 </span><span class="lineCov">    1910490 :     ParametersKey::ParametersKey(float k, float sigma, float mu) {</span>
<span class="lineNum">      13 </span><span class="lineCov">    1910490 :         kKey = _floatToIntBits(k);</span>
<span class="lineNum">      14 </span><span class="lineCov">    1910490 :         sigmaKey = _floatToIntBits(sigma);</span>
<span class="lineNum">      15 </span><span class="lineCov">    1910490 :         muKey = _floatToIntBits(mu);</span>
<span class="lineNum">      16 </span><span class="lineCov">     955245 :         _createKey();</span>
<a name="17"><span class="lineNum">      17 </span><span class="lineCov">    1910490 :     }</span></a>
<span class="lineNum">      18 </span>            :     
<span class="lineNum">      19 </span><span class="lineCov">   10581464 :     ParametersKey::ParametersKey(const ParametersKey&amp; other)</span>
<span class="lineNum">      20 </span><span class="lineCov">    5290732 :        : kKey(other.kKey), sigmaKey(other.sigmaKey), muKey(other.muKey) {</span>
<span class="lineNum">      21 </span><span class="lineCov">    5290732 :         _createKey();</span>
<a name="22"><span class="lineNum">      22 </span><span class="lineCov">   10581464 :     }</span></a>
<span class="lineNum">      23 </span>            :     
<span class="lineNum">      24 </span><span class="lineCov">   14402440 :     ParametersKey::~ParametersKey() {</span>
<a name="25"><span class="lineNum">      25 </span><span class="lineCov">   13447196 :     }</span></a>
<span class="lineNum">      26 </span>            :         
<span class="lineNum">      27 </span><span class="lineCov">    2866736 :     uint32_t ParametersKey::_floatToIntBits(float f) {</span>
<span class="lineNum">      28 </span>            :         // adapted from nvdia Cg source code which is now avail under a non-restrictive, free license
<span class="lineNum">      29 </span>            :         // http://www.nvidia.com/object/IO_20020719_7269.html
<span class="lineNum">      30 </span><span class="lineCov">    2866736 :         if (isnan(f)) {</span>
<span class="lineNum">      31 </span><span class="lineNoCov">          0 :             return 0x7fc00000;</span>
<span class="lineNum">      32 </span>            :         } else {
<span class="lineNum">      33 </span><span class="lineCov">    2866736 :             union int_float_bits u;</span>
<span class="lineNum">      34 </span><span class="lineCov">    2866736 :             u.f = f;</span>
<span class="lineNum">      35 </span><span class="lineCov">    2866736 :             return u.i;</span>
<span class="lineNum">      36 </span>            :         }
<a name="37"><span class="lineNum">      37 </span><span class="lineCov">    2866736 :     }</span></a>
<span class="lineNum">      38 </span>            :     
<span class="lineNum">      39 </span><span class="lineCov">     607417 :     float ParametersKey::_intBitsToFloat(uint32_t b) {</span>
<span class="lineNum">      40 </span><span class="lineCov">     607417 :         union int_float_bits u;</span>
<span class="lineNum">      41 </span><span class="lineCov">     607417 :         u.i = b;</span>
<span class="lineNum">      42 </span><span class="lineCov">     607417 :         return u.f;</span>
<span class="lineNum">      43 </span>            :         //float f;
<span class="lineNum">      44 </span>            :         //memcpy(&amp;f, &amp;b, sizeof(f));
<span class="lineNum">      45 </span>            :         //return f;
<a name="46"><span class="lineNum">      46 </span>            :     }    </a>
<span class="lineNum">      47 </span>            :     
<span class="lineNum">      48 </span><span class="lineCov">    2866736 :     bool ParametersKey::isnan(float s) {</span>
<span class="lineNum">      49 </span>            :         // By IEEE 754 rule, NaN is not equal to NaN
<span class="lineNum">      50 </span><span class="lineCov">    2866736 :         return s != s;</span>
<a name="51"><span class="lineNum">      51 </span>            :     }</a>
<span class="lineNum">      52 </span>            : 
<span class="lineNum">      53 </span><span class="lineCov">     101425 :     void ParametersKey:: decodeToParams(float* k, float* sigma, float* mu) {</span>
<span class="lineNum">      54 </span><span class="lineCov">     101425 :         *k = _intBitsToFloat(kKey);</span>
<span class="lineNum">      55 </span><span class="lineCov">     101425 :         *sigma = _intBitsToFloat(sigmaKey);</span>
<span class="lineNum">      56 </span><span class="lineCov">     101425 :         *mu = _intBitsToFloat(muKey);</span>
<a name="57"><span class="lineNum">      57 </span><span class="lineCov">     101425 :     }</span></a>
<span class="lineNum">      58 </span>            :     
<span class="lineNum">      59 </span>            :     string ParametersKey::_getKey() const {
<span class="lineNum">      60 </span><span class="lineCov">    2543411 :         return key;</span>
<a name="61"><span class="lineNum">      61 </span>            :     }</a>
<span class="lineNum">      62 </span>            :     
<span class="lineNum">      63 </span>            :     void ParametersKey::_createKey() {
<span class="lineNum">      64 </span>            : 
<span class="lineNum">      65 </span><span class="lineCov">    6245977 :         _writeIntToCharBytes(&amp;kKey);</span>
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span><span class="lineCov">    6245977 :         _writeIntToCharBytes(&amp;sigmaKey);</span>
<span class="lineNum">      68 </span>            : 
<span class="lineNum">      69 </span><span class="lineCov">    6245977 :         _writeIntToCharBytes(&amp;muKey);</span>
<span class="lineNum">      70 </span>            : 
<a name="71"><span class="lineNum">      71 </span><span class="lineCov">    6245977 :     }</span></a>
<span class="lineNum">      72 </span>            :     
<span class="lineNum">      73 </span><span class="lineCov">   18737931 :     void ParametersKey::_writeIntToCharBytes(const uint32_t *readInt) {</span>
<span class="lineNum">      74 </span>            :         
<span class="lineNum">      75 </span>            :         // assuming that string does not take more than 8 bits from a char
<span class="lineNum">      76 </span><span class="lineCov">  187379310 :         for (int i = 0; i &lt; 4; i++) {</span>
<span class="lineNum">      77 </span><span class="lineCov">   74951724 :             int shift = i * 8;</span>
<span class="lineNum">      78 </span><span class="lineCov">   74951724 :             uint32_t a = (*readInt &gt;&gt; shift) &amp; 0xff;</span>
<span class="lineNum">      79 </span><span class="lineCov">   74951724 :             char b = (char) a;</span>
<span class="lineNum">      80 </span><span class="lineCov">   74951724 :             key.push_back(b);</span>
<span class="lineNum">      81 </span><span class="lineCov">   74951724 :         }</span>
<a name="82"><span class="lineNum">      82 </span><span class="lineCov">   18737931 :     }</span></a>
<span class="lineNum">      83 </span>            :     
<span class="lineNum">      84 </span>            :     uint32_t ParametersKey::_getKKey() const {
<span class="lineNum">      85 </span><span class="lineCov">    2519528 :         return kKey;</span>
<a name="86"><span class="lineNum">      86 </span>            :     }</a>
<span class="lineNum">      87 </span>            :     
<span class="lineNum">      88 </span>            :     uint32_t ParametersKey::_getSigmaKey() const {
<span class="lineNum">      89 </span><span class="lineCov">     295660 :         return sigmaKey;</span>
<a name="90"><span class="lineNum">      90 </span>            :     }</a>
<span class="lineNum">      91 </span>            :     
<span class="lineNum">      92 </span>            :     uint32_t ParametersKey::_getMuKey() const {
<span class="lineNum">      93 </span><span class="lineCov">     274462 :         return muKey;</span>
<a name="94"><span class="lineNum">      94 </span>            :     }</a>
<span class="lineNum">      95 </span>            :     
<span class="lineNum">      96 </span><span class="lineCov">          1 :     bool ParametersKey::operator==(ParametersKey &amp; other)const {</span>
<span class="lineNum">      97 </span><span class="lineCov">          1 :         if (kKey != other.kKey) { return false; }</span>
<span class="lineNum">      98 </span><span class="lineCov">          1 :         if (sigmaKey != other.sigmaKey) { return false; }</span>
<span class="lineNum">      99 </span><span class="lineCov">          1 :         if (muKey != other.muKey) { return false; }</span>
<a name="100"><span class="lineNum">     100 </span><span class="lineCov">          1 :         return true;</span></a>
<span class="lineNum">     101 </span><span class="lineCov">          1 :     }</span>
<span class="lineNum">     102 </span><span class="lineNoCov">          0 :     bool ParametersKey::operator!=(ParametersKey &amp; other)const {</span>
<span class="lineNum">     103 </span><span class="lineNoCov">          0 :         if (kKey != other.kKey) { return true; }</span>
<span class="lineNum">     104 </span><span class="lineNoCov">          0 :         if (sigmaKey != other.sigmaKey) { return true; }</span>
<span class="lineNum">     105 </span><span class="lineNoCov">          0 :         if (muKey != other.muKey) { return true; }</span>
<span class="lineNum">     106 </span><span class="lineNoCov">          0 :         return false;</span>
<a name="107"><span class="lineNum">     107 </span><span class="lineNoCov">          0 :     }</span></a>
<span class="lineNum">     108 </span>            :    
<span class="lineNum">     109 </span><span class="lineNoCov">          0 :     bool operator==(ParametersKey const &amp; pk0, ParametersKey const &amp; pk1) {</span>
<span class="lineNum">     110 </span><span class="lineNoCov">          0 :         if (pk0.kKey != pk1.kKey) { return false; }</span>
<span class="lineNum">     111 </span><span class="lineNoCov">          0 :         if (pk0.sigmaKey != pk1.sigmaKey) { return false; }</span>
<span class="lineNum">     112 </span><span class="lineNoCov">          0 :         if (pk0.muKey != pk1.muKey) { return false; }</span>
<span class="lineNum">     113 </span><span class="lineNoCov">          0 :         return true;</span>
<a name="114"><span class="lineNum">     114 </span><span class="lineNoCov">          0 :     }</span></a>
<span class="lineNum">     115 </span>            :     
<span class="lineNum">     116 </span><span class="lineNoCov">          0 :     bool operator!=(ParametersKey const &amp; pk0, ParametersKey const &amp; pk1) {</span>
<span class="lineNum">     117 </span><span class="lineNoCov">          0 :         if (pk0.kKey != pk1.kKey) { return true; }</span>
<span class="lineNum">     118 </span><span class="lineNoCov">          0 :         if (pk0.sigmaKey != pk1.sigmaKey) { return true; }</span>
<span class="lineNum">     119 </span><span class="lineNoCov">          0 :         if (pk0.muKey != pk1.muKey) { return true; }</span>
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :         return false;</span>
<span class="lineNum">     121 </span><span class="lineNoCov">          0 :     }</span>
<span class="lineNum">     122 </span>            :     
<span class="lineNum">     123 </span>            : } // end namespace
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
